<template>
	<view>
		<head-navbar :back="true">
			<view>
				<text>余额提现</text>
			</view>
		</head-navbar>
		<view class="cashBox">
		<view class="cash">
			<view class="title">提现余额</view>
			<view class="middle">
				<view class="danWei">￥</view>
				<input type="digit" placeholder="请输入提现金额" v-model="zuanshiNum" />
			</view>
			<view class="down">
				<view class="left">余额：{{money}}</view>
				<view class="right" v-if="$store.state.shopDataBody.balanceWithdrawalTaxRate != 0">手续费：{{Math.floor($store.state.shopDataBody.balanceWithdrawalTaxRate*zuanshiNum*100)/100}}</view>
			</view>
		</view>
		</view>
		<view class="bankBox">
		<view class="bank">
			<view class="title">提现账户</view>
			<view class="bankList">
				<!-- <view class="left">
					<label class="radio">
						<radio color="#FF4900" value="r1" :checked="checked == 1" />
					</label>
				</view> -->
				<view class="right">
					<view class="cardName">{{auth.bankName?'银行名称：' + auth.bankName:'未实名认证'}}</view>
					<view class="cardNum">{{auth.bankNo?'银行卡号码：' + auth.bankNo : ''}}</view>
				</view>
			</view>
			</view>
			<!-- <view class="bankList">
				<view class="left">
					<label class="radio">
						<radio color="#FF4900" value="2" :checked="checked == 2" />
					</label>
				</view>
				<view class="right">
					<view class="cardName">支付宝</view>
					<view class="cardNum">{{accountList.aliPayAccount || "14764648198@qq.com"}}</view>
				</view>
			</view> -->
		</view>
		<view class="btn" @click="submit">
			<button>确认提现</button>
		</view>
		<ssPaymentPassword ref="paymentPassword" :mode="mode" :digits="6" :forget="false" @submit="submitHandle" />
	</view>
</template>

<script>
	import ssPaymentPassword from '@/components/sanshui-payment-password'
	import {
		withDrawal,
		getPayAccount,
		getAuthInfo
	} from '@/api/user/index.js';
	export default {
		components:{
		    ssPaymentPassword
		},
		data() {
			return {
				accountList:{},
				mode:1,
				type:null,
				title:'',
				tip:'',
				money:'',
				subUserCode:'',
				zuanshiNum:'',
				userInfont:null,
				auth:{},
				remark:'',
				reg:/^\d+(\.\d{0,2})?$/
			}
		},
		onLoad(option) {
			this.money = option.money;
			this.getAuthInfoFuc()
		},
		methods: {
			getAuthInfoFuc(){
				getAuthInfo().then(res=>{
					this.auth = res.data.obj.auth
				})
			},
			submit() {
				if(this.zuanshiNum == ''){
					uni.showToast({
						title:'转账数量不能为0',
						icon:'none'
					})
					return
				}
				if(!this.reg.test(this.zuanshiNum)){
					uni.showToast({
						title:'转账数量最多两位小数',
						icon:'none'
					})
					return
				}
				// <view class="text" v-show="auth.authStatus==0">未认证</view>
				// <view class="text" v-show="auth.authStatus==1">认证中</view>
				// <view class="text" v-show="auth.authStatus==2">已认证</view>
				// <view class="text" v-show="auth.authStatus==3">认证失败</view>
				if(this.auth.authStatus == 0){
					uni.showToast({
						title:'未实名',
						icon:'none'
					})
					return
				}
				if(this.auth.authStatus == 1){
					uni.showToast({
						title:'实名收款正在认证中',
						icon:'none'
					})
					return
				}
				if(this.auth.authStatus == 3){
					uni.showToast({
						title:'实名收款认证失败，请重新任重',
						icon:'none'
					})
					return
				}
				this.$refs.paymentPassword.modalFun('show');
			},
			
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			// async getAccountPay() {
			// 	try {
			// 		let parmas = {
			// 			pageNum: 1,
			// 			pageSize: 20
			// 		}
			// 		const ret = await getPayAccount(parmas);
			// 		console.log(ret)
			// 		this.accountList = ret.data.obj;
			// 	} catch (error) {

			// 	}
			// },
			async submitHandle(e) {
				try {
					let parmas = this.params;
					const ret = await withDrawal({type: 1,applyAmount: this.zuanshiNum,tradePwd: e.value,remark:this.remark});
					uni.showToast({
						title:'提现成功',
						icon:'none'
					})
					this.money = this.money - this.zuanshiNum
					this.subUserCode = ''
					this.zuanshiNum = ''
					this.$api.prePage().status = 'loading'
					this.$api.prePage().list = []
					this.$api.prePage().pageNo = 1
					this.$api.prePage().moneyNumber = this.money
					this.$api.prePage().getRecordList()
				} catch (error) {
					console.log(error)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.down{
				  margin-top: 30rpx;
				  font-size: 26rpx;
				  display: flex;
				  justify-content: space-between;
				  .left{
					  color: #FF5C02;
				  }
				  .right{
					   color: #9A9A9A;
				  }
	}
	.rightText {
		view {
			width: 140rpx;
		}

		font-size: 24rpx;
	}

	.radio {
		color: #FFFFFF !important;
	}
     .cashBox{
		 padding: 30rpx;
	 }
	.cash {
		padding: 30rpx;
		background: #FFFFFF;
		border-radius: 20rpx;

		.title {
			font-size: 30rpx;
			margin-bottom: 10rpx;
		}

		.middle {
			display: flex;
			align-items: center;
			padding: 30rpx 0;
			border-bottom: 1px solid #f4f4f4;

			.danWei {
				flex: none;
				font-size: 45rpx;
				font-weight: bold;
			}

			input {
				flex: auto;
				font-size: 26rpx;
				margin: 0 20rpx;
			}

			.all {
				flex: none;
			}
		}

		.charge {
			margin-top: 20rpx;
			color: #858585;
		}
	}
     .bankBox{
		 padding: 30rpx;
		 padding-top: 0rpx;
	 }
	.bank {
		background: #FFFFFF;
		border-radius: 20rpx;

		.title {
			font-size: 30rpx;
			padding: 20rpx;
			border-bottom: 1px solid #f4f4f4;
		}

		.bankList {
			padding: 20rpx;
			display: flex;
			align-items: center;

			.left {
				flex: none;
				margin-right: 20rpx;
			}

			.right {
				flex: auto;
                 .cardName{
					 color: #949494;
				 }
				.cardNum {
					// font-size: 24rpx;
					color: #949494;
					margin-top: 20rpx;
					margin-top: 10rpx;
				}
			}
		}
	}

	.btn {
		padding: 50rpx 30rpx;

		button {
			background: #FF4900;
			border-radius: 100rpx;
			color: #FFFFFF;
		}
	}
</style>